package com.kaluli.project.utils.zhuozhi;

import java.sql.Timestamp;
import java.util.LinkedList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.kaluli.project.domain.entity.ZZOrder;
import com.kaluli.project.domain.entity.ZZOrderDetail;
import com.kaluli.project.domain.entity.ZZRecipient;

/**
 * 卓志OP平台数据接口构造类
 * @author zyzowen1944
 *
 */
public class ZZJsonBuilder {
	private static ZZJsonBuilder zzjsonBuilder = null;
	
	public static ZZJsonBuilder getInstance(){
		synchronized(ZZJsonBuilder.class){
			if(zzjsonBuilder==null){
				zzjsonBuilder = new ZZJsonBuilder();
			}
			return zzjsonBuilder;
		}
	}
	
	public String objToJson(ZZOrder order){
		String json = null;
		json = JSON.toJSONString(order);
		return json;
	}
	public static void main(String s[]){
		ZZOrder root = new ZZOrder();
		root.setOrderId("123123123123");
		root.setOrderDate(new Timestamp(System.currentTimeMillis()));
		root.setCustomerId("123123123");
		root.setOrderType(1);
		ZZOrderDetail good = new ZZOrderDetail();
		good.setGoodId("123123123");
		good.setAmount(2);
		good.setPrice(13.33);
		List<ZZOrderDetail> goodList = new LinkedList<ZZOrderDetail>();
		goodList.add(good);
		
		ZZRecipient recipient = new ZZRecipient();
		recipient.setName("owen");
		recipient.setMobilePhone("13901899768");
		
		root.setGoodList(goodList);
		root.setRecipient(recipient);
		
		ZZJsonBuilder jb = ZZJsonBuilder.getInstance();
		String json = jb.objToJson(root);
		System.out.println(json);
		
	}
}
